package com.thb.pay.manage.web.payment;


import com.thb.pay.api.payment.PayChannelServiceApi;
import com.thb.pay.api.payment.vo.req.ChannelConfigPageReq;
import com.thb.pay.api.payment.vo.req.ChannelConfigReq;
import com.thb.pay.api.payment.vo.resp.PayChannelVo;
import com.thb.pay.core.utils.PageResult;
import com.thb.pay.core.utils.R;
import com.thb.pay.manage.comm.controller.BaseController;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 渠道配置信息表 前端控制器
 * </p>
 *
 * @author lucky
 * @since 2019-07-21
 */
@Slf4j
@RestController
@RequestMapping("api/sys/channelConfig")
public class ChannelConfigController extends BaseController {

    @Autowired
    private PayChannelServiceApi payChannelServiceApi;

    @PostMapping("/list")
    public R list(@RequestBody ChannelConfigPageReq pageReq) {
        PageResult<PayChannelVo> pageResult = payChannelServiceApi.findPage(pageReq);
        return R.okData(pageResult);
    }

    @RequestMapping("/get")
    public R get(@RequestParam("id") Long id) {
        PayChannelVo resultData = payChannelServiceApi.getById(id);
        return R.okData(resultData);
    }

    @PostMapping("/add")
    public R add(@RequestBody ChannelConfigReq channelConfigReq) {
        payChannelServiceApi.add(channelConfigReq);
        return R.ok();
    }

    @PostMapping("/update")
    public R update(@RequestBody ChannelConfigReq channelConfigReq) {
        payChannelServiceApi.update(channelConfigReq);
        return R.ok();
    }
}
